import psycopg2
from datagenerator import *

conn = psycopg2.connect(database="lab3", user="testuser", password="test123", host="yourhost", port="5432")
cur = conn.cursor()
num = 3
range_num = 1000
error = 0
# for i in range(range_num):
#     try:
#         data_dept(cur, num)
#         conn.commit()
#     except Exception as e:
#         error += 1
#         conn.commit()
# print('now dept finish, error:', error)
# for i in range(range_num):
#     try:
#         data_teacher(cur, num)
#         conn.commit()
#     except Exception as e:
#         error += 1
#         conn.commit()
# print('now teacher finish, error:', error)
# for i in range(range_num):
#     try:
#         data_course(cur, num)
#         conn.commit()
#     except Exception as e:
#         error += 1
#         conn.commit()
# print('now course finish, error:', error)
# for i in range(range_num):
#     try:
#         data_classroom(cur, num)
#         conn.commit()
#     except Exception as e:
#         error += 1
#         conn.commit()
# print('now classroom finish, error:', error)
for i in range(range_num * 10):
    try:
        data_project(cur, num)
        conn.commit()
        print(i)
    except Exception as e:
        error += 1
        conn.commit()
print('now project finish, error:', error)
# for i in range(range_num):
#     try:
#         data_student(cur, num)
#         conn.commit()
#     except Exception as e:
#         error += 1
#         conn.commit()
# print('now student finish, error:', error)
# for i in range(range_num):
#     try:
#         data_contacts(cur, num)
#         conn.commit()
#     except Exception as e:
#         error += 1
#         conn.commit()
# print('now contacts finish, error:', error)
for i in range(range_num):
    try:
        data_take(cur, num)
        conn.commit()
    except Exception as e:
        error += 1
        conn.commit()
print('now take finish, error:', error)
for i in range(range_num):
    try:
        data_works(cur, num)
        conn.commit()
    except Exception as e:
        error += 1
        conn.commit()
print('now works finish, error:', error)
conn.close()
